<?php

/*
 * Copyright (c) Madbit 2012. All Rights Reserved.
 * Reproduction in whole or in part is prohibited without the
 * written consent of the copyright owner.
 */

$dropDB = "IF EXISTS DROP DATABASE %s;";

$createDB = "CREATE DATABASE %s;";

$createTables = "CREATE TABLE categories (
idc INT NOT NULL AUTO_INCREMENT,
name VARCHAR(150) NOT NULL,
path VARCHAR(255) NOT NULL,
view_order INT,
parent_dir INT,

PRIMARY KEY(idc)
) ENGINE=InnoDB;


CREATE TABLE users (
idu INT NOT NULL AUTO_INCREMENT,
username VARCHAR(150) NOT NULL,
password VARCHAR(255),
usertype VARCHAR(255),
usergroup VARCHAR(150),
PRIMARY KEY(idu)
) ENGINE=InnoDB;


CREATE TABLE files (
idf INT NOT NULL AUTO_INCREMENT,
title VARCHAR(255) NOT NULL,
path VARCHAR(255) NOT NULL,
filename VARCHAR(255) NOT NULL,
type VARCHAR(50) NOT NULL,
size int(10) NOT NULL,
date_ins DATETIME,
active BOOLEAN default 1,
owner int(10),
permits int(3) default 755,
view_order INT,
idc INT NOT NULL,
PRIMARY KEY(idf),
FOREIGN KEY(idc) REFERENCES categories(idc) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY(owner) REFERENCES users(idu) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;


CREATE TABLE links (
idl INT NOT NULL AUTO_INCREMENT,
title VARCHAR(255) NOT NULL,
url VARCHAR(255) NOT NULL,
date_ins DATETIME,
active BOOLEAN default 1,
owner int(10),
permits int(3) default 755,
idc INT NOT NULL,
PRIMARY KEY(idl),
FOREIGN KEY(idc) REFERENCES categories(idc) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY(owner) REFERENCES users(idu) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;";

$inizializeTables = "INSERT INTO categories (name,path,parent_dir) VALUES ('root','/','0')";



        
?>
